package designpattern.structural_patterns;
/*
 * Bridge pattern chi? khac' Strategy Pattern o? muc. dich' su? dung.
 * Strategy thi` duoc. su? dung voi' behavior
 * con Bride thi` duoc. su? dung. voi' structure
 * 
 */
public class BridgePattern {

	public class Abstraction{
		Implementor implementor;

		public Implementor getImplementor() {
			return implementor;
		}

		public void setImplementor(Implementor implementor) {
			this.implementor = implementor;
		}
		public void operation(){
			implementor.operationImpl();
		}
	}
	
	interface Implementor{
		void operationImpl();
	}
	
	public class ConcreteImplementorA implements Implementor{
		@Override
		public void operationImpl() {
			System.out.print("ConcreteImplementorA\n");
		}
	}
	public class ConcreteImplementorB implements Implementor{
		@Override
		public void operationImpl() {
			System.out.print("ConcreteImplementorB\n");
		}
	}
	
	public static void main(String[] args) {
		
		BridgePattern bridgePattern = new BridgePattern();
		Abstraction abstraction = bridgePattern.new Abstraction();
		//
		abstraction.setImplementor(bridgePattern.new ConcreteImplementorA());
		abstraction.operation();
		//
		abstraction.setImplementor(bridgePattern.new ConcreteImplementorB());
		abstraction.operation();
	}
}
